package com.bishe.dao;


import com.bishe.pojo.User;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.ibatis.annotations.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.List;

/**
 * 用户数据层
 * @date 2022/2/24 16:44
 */
public interface UserDao {

    @Select("select * from user")
    List<User> findAll();


    @Select("select * from user where userName = #{userName} and passWord = #{password} ")
    User checkUser(@Param("userName") String userName, @Param("password") String password);


    @Select("select * from user where id = #{id}")
    User findById(@Param("id") String id);

    @Delete("delete  from user where id = #{id}")
    void deleteById(@Param("id") String id);


    @Update("update user set " +
            "id = #{id}," +
            "userName = #{userName}," +
            "nikName = #{nikName}," +
            "passWord = #{passWord}," +
            "age = #{age}," +
            "phone = #{phone}," +
            "sex = #{sex}," +
            "createTime = #{createTime}" +
            "where id = #{id}")
    void updateById(User user);


    @Insert("insert into user(id,userName,phone,nikName,passWord,age,sex,createTime) " +
            "values(#{id},#{userName},#{phone},#{nikName},#{passWord},#{age},#{sex},#{createTime})")
    void save(User user);
}
